package newsletterApi

import (
	"github.com/Sir-yuChen/funAnalyse/model"
	"github.com/Sir-yuChen/funAnalyse/model/common/response"
	"github.com/Sir-yuChen/funAnalyse/utils"
	"github.com/gin-gonic/gin"
	"github.com/gin-gonic/gin/binding"
)

type StockUserGroupController struct{}

// GetStockUserGroup 多条件查询
// @Summary stockUserGroup get
// @Tags 接口归类
// @Accept application/json
// @Produce application/json
// @Param data body model.StockUserGroupModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/newsletter/getStockUserGroup [GET]
func (b *StockUserGroupController) GetStockUserGroup(c *gin.Context) {
	var req model.StockUserGroupModel
	if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
		utils.ErrValidatorResp(err, "GetStockUserGroup", req, c)
		return
	}
	apiReturn := stockUserGroupService.GetStockUserGroup(&req)
	response.WithApiReturn(apiReturn, c)
	return
}

// InsertStockUserGroup
// @Summary stockUserGroup insert
// @Tags 接口归类
// @Accept application/json
// @Produce application/json
// @Param data body model.StockUserGroupModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/newsletter/insertStockUserGroup [POST]
func (b *StockUserGroupController) InsertStockUserGroup(c *gin.Context) {
	var req model.StockUserGroupModel
	if err := c.ShouldBind(&req); err != nil {
		utils.ErrValidatorResp(err, "InsertStockUserGroup", req, c)
		return
	}
	apiReturn := stockUserGroupService.InsertStockUserGroup(&req, c)
	response.WithApiReturn(apiReturn, c)
	return
}

// UpdateStockUserGroup
// @Summary  update
// @Tags 接口归类
// @Accept application/json
// @Produce application/json
// @Param data body model.StockUserGroupModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/newsletter/updateStockUserGroup [POST]
func (b *StockUserGroupController) UpdateStockUserGroup(c *gin.Context) {
	var req model.StockUserGroupModel
	if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
		utils.ErrValidatorResp(err, "UpdateStockUserGroup", req, c)
		return
	}
	apiReturn := stockUserGroupService.UpdateStockUserGroup(&req)
	response.WithApiReturn(apiReturn, c)
	return
}

// DelStockUserGroup
// @Summary stockUserGroup del
// @Tags 接口归类
// @Accept application/json
// @Produce application/json
// @Param data body model.StockUserGroupModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/newsletter/delStockUserGroup [Get]
func (b *StockUserGroupController) DelStockUserGroup(c *gin.Context) {
	var req model.StockUserGroupModel
	if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
		utils.ErrValidatorResp(err, "DelstockUserGroup", req, c)
		return
	}
	apiReturn := stockUserGroupService.DelStockUserGroup(&req)
	response.WithApiReturn(apiReturn, c)
	return
}
